﻿
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.IO;

namespace AMG.UserForms.ViewModels
{
    public class ArchitecturalChange : ViewModelBase
    {
        //Forms to select
        [DisplayName("Your Name")]
        [Required]
        public string MemberName { get; set; }

        [DisplayName("Association Name")]
        [Required]
        public string AssociationName { get; set; }

        [DisplayName("Property Address Line 1")]
        [Required]
        public string Address1 { get; set; }

        [DisplayName("Property Address Line 2")]
        public string Address2 { get; set; }

        [Required]
        public string City { get; set; }

        [Required]
        public string State { get; set; }

        [Required]
        public string Phone { get; set; }

        [Required]
        public string Email { get; set; }

        [DisplayName("Proposed Change")]
        [Required]
        public string ProposedChange { get; set; }

        [DisplayName("Description of the proposed change")]
        [Required]
        public string Description { get; set; }

        [DisplayName("Elevations")]
        public bool ElevationsAttached { get; set; }

        [DisplayName("Site Plan")]
        public bool SitePlanAttached { get; set; }

        [DisplayName("Color Samples")]
        public bool ColorSamplesAttached { get; set; }

        [DisplayName("Extras")]
        public bool ExtrasAttached { get; set; }

        public List<UploadedFile> FileList { get; set; }

        private List<Agreement> _agreementList = null;
        public List<Agreement> AgreementList
        {
            get
            {
                if (_agreementList == null)
                {
                    _agreementList = new List<Agreement>
                            {
                                new Agreement
                                {
                                    AgreementText = "Your association may require additional information in order to complete a review of your proposed project.  Typically you can expect to hear from your association’s review committee in about 30 days (seldom in less than 21 days).  If you do not receive an email acknowledging that all needed information has been received, within 5 business days, assume it has not been received and contact your manager by email or telephone."
                                },
                                new Agreement
                                {
                                    AgreementText = "I/We agree that it is my/our responsibility and obligation to obtain all required building permits, to contact all utility providers to locate lines and pipes, and to construct the improvements in a workmanlike manner, in conformance with all applicable building and zoning codes."
                                },
                                new Agreement
                                {
                                    AgreementText = "I/We agree the to be solely responsible for determining whether the improvements, alterations, or additions described above comply with all applicable laws, rules, regulations, codes, and ordinances.  The Architectural Review Committee and the Association shall have no liability or obligation to determine whether such improvements, alterations, and additions comply with any such laws, rules, regulations, codes, or ordinances. If a member begins a project and cannot complete it due to construction issues that require changes, the member must resubmit their application, including all changes for written approval prior to continuing and finishing the project.  It is further acknowledged that I/we will within 90 days from the date of the approval of this form complete the requested work.  If unable to complete the work in time, I/we agree to request a time extension which must be approved in writing."
                                },
                                new Agreement
                                {
                                    AgreementText = "I/We agree not to begin this proposed property improvement(s) until the Architectural Review Committee notifies me in writing of its approval.  If any change is made that has not been approved, the Committee has the right to ask me to remove the improvement from my property, and I agree to do so.  I/We understand if so notified and I fail to remove the improvement within thirty (30) days of notification I authorize the Association and/or its’ agent to remove same, and that I am fully responsible for the entire cost of said removal/restoration.  Also, I/we agree to notify the Committee upon completion of the improvement(s) and authorize them access to the property to inspect the improvement(s)."
                                }
                                //new Agreement
                               // {
                                 //   AgreementText = "By typing my name below I/we agree it is a binding electronic signature."
                               // }
                            };
                }
                return _agreementList;
            }
            set
            {
                _agreementList = value; 
            }
        }

        [DisplayName("Agree by entering your name name")]
        [Required]
        public string MemberSignature { get; set; }

        [DisplayName("Date")]
        public DateTime DateSubmitted
        {
            get
            {
                return DateTime.Now;
            }
        }

        [Required(ErrorMessage = "You must agree to all terms")]
        public bool? AllAgreementsChecked { get; set; }
    }

    public class Agreement
    {
        [Required]
        public bool AgreeChecked { get; set; }

        public string AgreementText { get; set; }
    }

    public class UploadedFile
    {
        public string FileName { get; set; }
        public byte[] FileData { get; set; }
    }
}
